function myNew(fun){
    const o = Object.create(fun.prototype)
    const k = fun.apply(o)
    if(typeof k === 'object'){
        return k
    }else{
        return o
    }
}


/*
关于new的练习题
*/
function T1() {
    this.name = 't1';
    this.age = 19;
}

function T2() {
    this.name = 't2';
    this.age = 19;
    return 19;
}

function T3() {
    this.name = 't3';
    this.age = 19;
    return {name: 't', age: 20};
}

function T4() {
    this.name = 't4';
    this.age = 19;
}

console.log(new T1());
console.log(new T2());
console.log(new T3());
T4.prototype = new T1();
T4.prototype.type = 'expert';
const t4 = new T4();
console.log(t4); //{name:'t4',age:19}
console.log(t4.type); // 'expert'
console.log(t4 instanceof T1); // true
console.log(t4 instanceof T2); // false
console.log(t4 instanceof T4); // true
